﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;
using System.IO;

namespace PlexBB
{
    public class PlexBBConfigurationSection : ConfigurationSection
    {
        [ConfigurationProperty("connectionString")]
        public string ConnectionString
        {
            get
            {
                //#if PLEXBB_PRECOMPILED && DEBUG
                //                return HttpContext.Current.Server.MapPath("~/App_Data/PlexBB_Database28.mdf");
                //#else
                return (string)this["connectionString"];
                //#endif
            }
            set
            {
                this["connectionString"] = value;
            }
        }

        [ConfigurationProperty("urlParamPrefix")]
        [RegexStringValidator(@"^[a-zA-Z0-9\.\-_\$]*$")]
        public string UrlParamPrefix
        {
            get
            {
                return (string)this["urlParamPrefix"];
            }
            set
            {
                this["urlParamPrefix"] = value;
            }
        }

        [ConfigurationProperty("databaseTablePrefix", DefaultValue = "plexbb_")]
        [RegexStringValidator(@"^([a-zA-Z_]+[a-zA-Z0-9_]*)?$")]
        public string DatabaseTablePrefix
        {
            get
            {
                return (string)this["databaseTablePrefix"];
            }
            set
            {
                this["databaseTablePrefix"] = value;
            }
        }

        [ConfigurationProperty("baseDir", DefaultValue = "~/")]
        public string BaseDir
        {
            get
            {
                return (string)this["baseDir"];
            }
            set
            {
                this["baseDir"] = value;
            }
        }

        [ConfigurationProperty("forumUrl")]
        public string ForumUrl
        {
            get
            {
                return (string)this["forumUrl"];
            }
            set
            {
                this["forumUrl"] = value;
            }
        }

        [ConfigurationProperty("enableUrlRewriting", DefaultValue = false)]
        public bool EnableUrlRewriting
        {
            get
            {
                return this["enableUrlRewriting"] == null ? false : (bool)this["enableUrlRewriting"];
            }
            set
            {
                this["enableUrlRewriting"] = value;
            }
        }
    }
}
